{extend name='table'}

{block name="style"}
<style>
    .layui-table td .layui-table-cell {
        height: auto !important;
        overflow: visible;
        text-overflow: inherit;
        white-space: normal;
        word-break: break-all;
    }
    .layui-table td .layui-table-grrid-down{
        display: none;
    }
</style>
{/block}

{block name="content"}
<div class="layui-tab layui-tab-card">
    <div class="layui-tab-content">
        {include file='collect/claim/index_search'}
        <table id="ClaimRecord" data-url="{:sysuri('index')}" data-target-search="form.form-search"></table>
    </div>
</div>
<script>

    var maxWidth = window.innerWidth;
    var maxHeight = window.innerHeight;

    $(function () {
        // 隐藏hover
        $('.layui-tab-content').on('mouseenter', "tr", function(){
            $(this).parents('tr').removeClass('layui-table-hover');
            $(this).find('.layui-table-grid-down').hide();
        })
        $('.layui-tab-content').on('mouseenter', ".layui-table-cell", function(){
            $(this).parents('tr').removeClass('layui-table-hover');
            $(this).siblings('.layui-table-grid-down').hide();
        })
        $('.layui-tab-content').on('mouseenter', ".no_hover", function(){
            $(this).parents('tr').removeClass('layui-table-hover');
            $(this).parent().siblings('.layui-table-grid-down').hide();
        })

        $('#ClaimRecord').layTable({
            even: true, height: 'full',
            cols: [[
                {checkbox: true, fixed: true},
                {field: 'image_url', title: '{:lang("图片")}', width: 150, align: 'center',  templet:"#imgTpl"},
                {field: 'base_info', title: '{:lang("基本信息")}', minWidth: 220, align: 'left',templet:"#baseTpl"},
                {field: 'platform_text', title: '{:lang("认领平台")}', minWidth: 120, align: 'center'},
                {field: 'shop_text', title: '{:lang("认领店铺")}', minWidth: 120, align: 'center'},
                {field: 'create_at', title: '{:lang("时间")}', width: 200, align: 'left',templet:"#create_atTpl"},
            ]]
            ,done: function(res, curr, count){

                //动态监听表头高度变化，冻结行跟着改变高度
                $(".layui-table-header tr").resize(function () {
                    $(".layui-table-header  tr").each(function (index, val) {
                        $($(".layui-table-fixed .layui-table-header table tr")[index]).height($(val).height());
                    });
                });
                //初始化高度，使得冻结行表头高度一致
                $(".layui-table-header tr").each(function (index, val) {
                    $($(".layui-table-fixed .layui-table-header table tr")[index]).height($(val).height());
                });
                //动态监听表体高度变化，冻结行跟着改变高度
                $(".layui-table-body tr").resize(function () {
                    $(".layui-table-body  tr").each(function (index, val) {
                        $($(".layui-table-fixed .layui-table-body table tr")[index]).height($(val).height());
                    });
                });
                //初始化高度，使得冻结行表体高度一致
                $(".layui-table-body tr").each(function (index, val) {
                    $($(".layui-table-fixed .layui-table-body table tr")[index]).height($(val).height());
                })
          }
        });

        // 指向元素为 `<select lay-filter="test"></select>` 的选择事件
        form.on('select(platform)', function(data){

            $.ajax({
                type : 'get',
                url  : "{:sysuri('common/ajax/getShopUserList')}",
                data : {account_id:data.value},
                success:function (res) {
                    if (res.code == 1) {
                        var html = "<option value=''>{:lang('-- 请选择 --')}</option>";

                        let data = res.data;
                        for (var i in data) {

                            html += "<option value='"+i+"'>"+data[i]+"</option>";
                        }

                        $('.claim-user-id').html(html);

                        layui.form.render('select'); // 仅渲染 select 元素
                    }
                }
            })
        });
    });
</script>
<!--图片-->
<script type="text/html" id="imgTpl" >
    <img src="{{ d.image }}" class="preview-all" style="max-width: 80px;max-height: 80px;" data-tips-image data-tips-hover >
</script>
<!--基本信息-->
<script type="text/html" id="baseTpl" >
    <div>
        <span style="white-space: normal;padding-bottom:10px;word-break: break-all;font-size: 10px;color:#999;">{{ d.title }}</span><br>
        <span>产品ID：{{ d.goods_code }}</a></span><br>
    </div>
</script>
<!--时间-->
<script type="text/html" id="create_atTpl" >
    <div>
        <span>添加：{{ d.create_at }}</span><br>
        <span>认领人：{{ d.claim_user_text }}</span><br>
    </div>
</script>
{/block}
